package com.huika.renrench.control.my.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huika.lib.utils.MoneyShowTool;
import com.huika.renrench.GlobalApp;
import com.huika.renrench.R;
import com.huika.renrench.control.common.base.BaseAct;
import com.huika.renrench.utils.WebNetUtils;
import com.huika.renrench.view.TitleBarHelper;
import com.huika.renrench.view.webview.BaseWebViewAct;

/**
 * @author yangyuan
 * @date：2015年6月3日
 * @describe:借款管理	
 */
public class BorrowMoneyActivity extends BaseAct{

	private ImageView btn_policy_statement;//借款说明
	private TextView text_borrow_money;//借款金额
	
	private Button button_apply_for;//申请借款
	
	private LinearLayout lin_success_boot_record;//成功记录
	private LinearLayout lin_application_record;//申请记录
	
	@Override
	public void setRootView() {
		setContentView(R.layout.borrow_money_activity);
	}
	
	@Override
	protected void initWidget() {
		super.initWidget();
		new TitleBarHelper(this, R.string.common_index_my, -1, R.string.jie_management);
		
		btn_policy_statement = (ImageView) findViewById(R.id.btn_policy_statement);
		text_borrow_money = (TextView) findViewById(R.id.text_borrow_money);
		button_apply_for = (Button) findViewById(R.id.button_apply_for);
		lin_success_boot_record = (LinearLayout) findViewById(R.id.lin_success_boot_record);
		lin_application_record = (LinearLayout) findViewById(R.id.lin_application_record);
		
		setOnclickListener();
	}
	
	/** 控件添加监听器 */
	private void setOnclickListener() {
		btn_policy_statement.setOnClickListener(this);
		button_apply_for.setOnClickListener(this);
		lin_success_boot_record.setOnClickListener(this);
		lin_application_record.setOnClickListener(this);
	}
	
	@Override
	protected void onResume() {//实时改变数据
		super.onResume();
			text_borrow_money.setText(MoneyShowTool.twolastDF(GlobalApp.getInstance().getUserModel().getLoanAmount()));
	}
	
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
		case R.id.btn_policy_statement:
			Intent intent = new Intent(this, BaseWebViewAct.class);
			intent.putExtra(BaseWebViewAct.PAGE_URL, WebNetUtils.getWebUrl("11"));
			intent.putExtra(BaseWebViewAct.PAGE_TITLE, "借款细则");
			intent.putExtra(BaseWebViewAct.IS_SHOW_BOTTOM, false);
			intent.putExtra(BaseWebViewAct.IS_HELP_FEEDBACK, true);
			showActivity(this, intent);
			break;
		case R.id.button_apply_for:
//			showToastMsg("我要借款");
			Intent intentweb = new Intent(this, BaseWebViewAct.class);
			intentweb.putExtra(BaseWebViewAct.PAGE_URL, WebNetUtils.getWebUrl("4"));
			intentweb.putExtra(BaseWebViewAct.PAGE_TITLE, "我要借款");
			intentweb.putExtra("left", "返回");
			intentweb.putExtra(BaseWebViewAct.IS_SHOW_BOTTOM, false);
			intentweb.putExtra(BaseWebViewAct.IS_HELP_FEEDBACK, true);
			showActivity(this, intentweb);
			break;
		case R.id.lin_success_boot_record://成功借款记录
			Bundle bundle = new Bundle();
			bundle.putInt("type", 0);
			showActivity(this, BorrowRecordActivity.class,bundle);
			break;
		case R.id.lin_application_record://借款申请记录
			Bundle bundle1 = new Bundle();
			bundle1.putInt("type", 1);
			showActivity(this, BorrowRecordActivity.class,bundle1);
			break;
		}
	}

}
